<?
include("parametr.php");

echo "<head>
<title>Submit mail to lolita3dbot</title>
</head>
<BODY>
<H1>ADD/REMOVE YOUR MAIL TO LOLITA3DBOT CONTACT LIST</H1>";
echo "<form method=post action=mail.php>" ;
echo "<TABLE>" ;
echo "<TR><TD>msn</TD><TD><INPUT TYPE=text NAME=msn SIZE=50></INPUT></TD></TR>
      <TR><TD>icq</TD><TD><INPUT TYPE=text NAME=icq SIZE=50></INPUT></TD></TR>
      <TR><TD>yahoo</TD><TD><INPUT TYPE=text NAME=yahoo SIZE=50></INPUT></TD></TR>
      <TR><TD>jabber</TD><TD><INPUT TYPE=text NAME=jabber SIZE=50></INPUT></TD></TR>
      <TR><TD>gtalk</TD><TD><INPUT TYPE=text NAME=gtalk SIZE=50></INPUT></TD></TR>
      <TR><TD>aim</TD><TD><INPUT TYPE=text NAME=aim SIZE=50></INPUT></TD></TR>";
echo "</TABLE>" ;
echo "<INPUT TYPE=submit name=action value=add>" ;
echo "<INPUT TYPE=submit name=action value=delete>" ;
echo "</FORM>" ;

/* Connect base */
if(!$connect = mysql_connect($server,$user,$password)){
	echo "Connection to server failed<BR>";
	exit;
}

/* Action on the base : 
- add : add the form data into the base
- delete : delete the form data from the base */
if(isset($_POST["msn"]) || isset($_POST["icq"]) || isset($_POST["yahoo"]) || isset($_POST["jabber"]) || isset($_POST["gtalk"]) || isset($_POST["aim"])){
	if(isset($_POST["action"])){
		if($_POST["action"]== "add"){
			$strquery = "insert into mail values('".$_POST["msn"]."','".$_POST["icq"]."','".$_POST["yahoo"]."','".$_POST["jabber"]."','".$_POST["gtalk"]."','".$_POST["aim"]."')";
			echo "<B>Mail added</B><BR><BR>";
		}
		if($_POST["action"]== "delete"){
			$strquery = "delete from mail where msn like '%".$_POST["msn"]."%' AND icq like '%".$_POST["icq"]."%' AND yahoo like '%".$_POST["yahoo"]."%' AND jabber like '%".$_POST["jabber"]."%' AND gtalk like '%".$_POST["gtalk"]."%' AND aim like '%".$_POST["aim"]."%'";
			echo "<B>Mail deleted.</B><BR><BR>";
		}
		/* execute query */
		if($res = mysql_db_query($basename,$strquery,$connect)){
			echo "<U>Completed !</U><BR>" ;
		}else{
			echo "<U>Failed. Try again later !</U><BR>" ;
		}
	}
}

